<?php
//订单
class orderMod extends base {

	//订单首页
	public function index() {
		
		$data['CardNo'] = $this->_G['member']['CardNo'];
		//当前订单
		$client = post_curl($data, 'BILL_GET_CURRENT');
		
		
		if ($client['status'] != 1) {
			//echo $client['status'];
			$this -> error(lang::get($client['status']));
		} else {					
			$noworder = $client['Msg'];		
			$this->assign('noworder',$noworder);			
		}
		//历史订单
		$BeginTime = strtotime('last month');
		$EndTime = time();
		$BeginDate = date('Y-m-d',$BeginTime);
		$EndDate = date('Y-m-d',$EndTime);
		
		$history = array(
		'CardNo'=>$this->_G['member']['CardNo'],
		'BeginDate'=>$BeginDate,
		'EndDate'=>$EndDate
		);

		$client = post_curl($history, 'BILL_GET_HISTORY');		
		if ($client['status'] != 1) {
			//echo $client['status'];
			$this -> error(lang::get($client['status']));
		} else {					
			$oldorder = $client['data'];
			//print_r($noworder);
			$this->assign('oldorder',$oldorder);			
		}
		
		$this->display();
	}
	//历史订单
	public function history(){
		//历史订单
		$BeginTime = strtotime('last month');
		$EndTime = time();
		$BeginDate = date('Y-m-d',$BeginTime);
		$EndDate = date('Y-m-d',$EndTime);
		
		$history = array(
		'CardNo'=>$this->_G['member']['CardNo'],
		'BeginDate'=>$BeginDate,
		'EndDate'=>$EndDate
		);
		if($_GET['BeginDate'] && $_GET['EndDate']){
			$history = array(
			'CardNo'=>$this->_G['member']['CardNo'],
			'BeginDate'=>$_GET['BeginDate'],
			'EndDate'=>$_GET['EndDate']
			);
		}

		$client = post_curl($history, 'BILL_GET_HISTORY');		
		
		if ($client['status'] != 1) {
			//echo $client['status'];
			$this -> error(lang::get($client['status']));
		} else {					
			$oldorder = $client['Msg'];
			$status = array('1'=>'预订','2'=>'入住','4'=>'结账','64'=>'取消');
			$this->assign('status',$status);
			//print_r($noworder);
			$this->assign('oldorder',$oldorder);			
		}
		
		$this->display();
	}
	//保存订单
	public function save(){
		$data = $_POST;
		$client = post_curl($data, 'BILL_SAVE');		
		if ($client['status'] != 1) {
			//echo $client['status'];
			$this -> error(lang::get($client['status']));
		} else {					
			$this->display();	
		}
	}
	//public function resver() {
	//$this->display();	
	//}
	//撤销订单
	public function cancel(){
		$data = array(
		'BillId'=>$_GET['BillId'],
		);
	
		$client = post_curl($data, 'BILL_CANCEL');		
		if ($client['status'] != 1) {
			//echo $client['status'];
			$this -> error(lang::get($client['status']));
		} else {					
			$this->success('订单取消成功');
		}
	}

}
?>